<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定义组件1</title>
    <script src="lib/vue.js"></script>
</head>

<body>
    <div id="box">
        <navbar></navbar>

    </div>

    <script>
        //全局组件
        Vue.component("navbar", {
            template: `<div>
        <button @click="handleBack">返回</button>
        navbar
        <button style="font-size:22px">主页</button>
        </div>`,
            methods: {
                handleBack() {
                    console.log("back");
                }
            }
        })
        new Vue({
            el: "#box",
            data: {

            },
            //局部组件
            components: {

            }
        })
    </script>

</body>

</html>